package cn.coopen.italktv.networkcheckdemo;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;

/**
 * 监听网络状态变化
 * 1. 网络已连接 从不可用变为可用
 * 2. 网络连接状态变化
 */
public class NetChanageReceiver extends BroadcastReceiver {

	@Override
	public void onReceive(Context context, Intent intent) {
		String action = intent.getAction();
		switch (action){
			case NetWorkCheckService.CONNECTIVITY_CHANGE:
				showMsg("网络连接发送变化");
				break;
			case NetWorkCheckService.NET_RECOVERY_ACTION:
				showMsg("互联网访问恢复正常");
				break;

		}
	}

	public void showMsg(String msg){
		Toast.makeText(BaseApplication.getInstance(),msg,Toast.LENGTH_SHORT).show();
	}
}
